<?php
    if(!$this->session->userdata('logged_in')) {
        redirect('logout');
    } else if($this->session->userdata('role') === 'viewer') {
        redirect('forbidden');
    }
?>
<div id="post_container">
    <div id="post_draft_wrapper">
        <div class="wrapper">
          <table id="big_table" class="display">
            <thead>
              <tr>
                <th>Title</th>
                <th></th>
                <th></th>
                <th></th>
              </tr>
            </thead>
            <tbody>
            </tbody>
          </table>
       </div>
       
       <script type="text/javascript">
          var oTable;

          $(document).ready(function()
          {
            oTable = $('#big_table').dataTable
            ({
              'iCookieDuration': 60,
              'bStateSave'     : true,
              'bServerSide'    : true,
              'bAutoWidth'     : true,
              'bProcessing': true,
              'sDom': 'T<"clear">lfrtip',
              'oTableTools': {
                "aButtons": [
                    {
                        "sExtends": "copy",
                        "mColumns": [0],
                        "sTitle": "Draft Posts List"
                    },
                    {
                        "sExtends": "csv",
                        "mColumns": [0],
                        "sTitle": "Draft Posts List"
                    },
                    {
                        "sExtends": "xls",
                        "mColumns": [0],
                        "sTitle": "Draft Posts List"
                    },
                    {
                        "sExtends": "pdf",
                        "mColumns": [0],
                        "sTitle": "Draft Posts List"
                    }
                ],
                "sSwfPath" : "<?php echo base_url();?>resources/swf/copy_csv_xls_pdf.swf"
              },
              'sPaginationType': 'full_numbers',
              'sAjaxSource'    : '<?php echo base_url();?>post_c/draft_post_list',
              'aoColumns'      : 
              [
                { 'sName' : 'title' },
                { 'sName' : 'publish' },
                { 'sName' : 'delete' },
                { 'sName' : 'date_time_pub' }
              ],
              'fnServerData': function(sSource, aoData, fnCallback)
              {
                $.ajax
                ({
                  'dataType': 'json',
                  'type'    : 'POST',
                  'url'     : sSource,
                  'data'    : aoData,
                  'success' : fnCallback
                });
              },
              "bJQueryUI": true,
              "iDisplayStart ":20,
              "oLanguage": {
                "sProcessing": "<img src='<?php echo base_url();?>resources/images/ajax-loader_dark.gif'>",
                "sSearch": "Search:"
              }, 
              "fnInitComplete": function() {
                oTable.fnAdjustColumnSizing();
              }
            });
            oTable.fnSetColumnVis(3, false);
            oTable.fnSort( [ [3,'desc'] ] );
          });
    </script>
    </div>
    <div class="balancer"></div>
</div>
